﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;

namespace NetCoreCMS.Web.Areas.WebApi.Controllers
{
    public class Favorite_EditController : UserController
    {
        public IFavoriteService _favorite { get; set; }
        [Authorize]
        [HttpGet]
        public IActionResult Get(int id,string remark)
        {
            var user = GetUserInfo();
            if (user == null)
            {
                return Ok(new { status = 0, msg = "请先登录！" });
            }
            var model = _favorite.GetModel(id);
            if(model==null)
                return Ok(new { status = 0, msg = "不存在！" });
            if(model.user_id!=user.id)
                return Ok(new { status = 0, msg = "别乱改！" });
            model.remark = remark;
            _favorite.Update(model);
            return Ok(new { status = 1, msg = "修改成功！", data = model });
        }
    }
}